<?php
if($_GET['user'] && $_GET['name'] && $_GET['confirm_token']){
	echo "激活失败,请不要篡改邮件链接";
}else{
	if(md5($_GET['name']."@mizhi.com") !== $_GET['confirm_token']){
		echo "激活失败,请不要篡改邮件链接";
	}else{
		$c = require("./common/conf/config.php");
		$conn = mysqli_connect($c["DB_HOST"],$c["DB_USER"],$c["DB_PWD"],$c["DB_NAME"]);
		if($_GET['user'] == 0){
			$re = mysqli_query($conn,"select * from user where uname='$_GET[name]'");
			$row = mysqli_fetch_assoc($re);
			if($row['status'] != 0){
				echo "请勿重复激活";
			}else{
				mysqli_query($conn,"update user set status='1' where uname='$_GET[name]'");
				mysqli_close($conn);
				header("Location:index.php");exit;
			}
		}else if($_GET['user'] == 1){
			$re = mysqli_query($conn,"select * from com where cname='$_GET[name]'");
			$row = mysqli_fetch_assoc($re);
			if($row['status'] != 0){
				echo "请勿重复激活";
			}else{
				mysqli_query($conn,"update com set status='0.5' where cname='$_GET[name]'");
				mysqli_close($conn);
				header("Location:index.php");exit;
			}
		}else{
			echo "激活失败,请不要篡改邮件链接";
		}
	}
}
?>